import sys

from PyQt5.QtWidgets import (

QApplication, QWidget, QVBoxLayout,

QScrollArea,

)

from PyQt5.QtGui import QPainter, QColor, QPen

from PyQt5.QtCore import Qt

class PaintWidget(QWidget):

    def __init__(self):

        super().__init__()

    def paintEvent(self, event):

        qp = QPainter()

        qp.begin(self)

        qp.setPen(QPen(QColor(0, 0, 255), 3, Qt.DotLine))

        r = event.rect()

        qp.drawLine(r.left(), r.top(), r.right(), r.bottom())

        qp.end()

class TopWidget(QWidget):

    def __init__(self):

        super().__init__()

        self.setUI()

        self.show()

    def setUI(self):

        self.setGeometry(300, 300, 800, 400)

        self.topFiller = PaintWidget()

        self.topFiller.setMinimumSize(1200, 2000)

        self.scroll = QScrollArea()

        self.scroll.setWidget(self.topFiller)

        self.vbox = QVBoxLayout()

        self.vbox.addWidget(self.scroll)

        self.setLayout(self.vbox)

    def keyPressEvent(self, event):

        if event.key() == Qt.Key_Escape:

            self.close()

if __name__ == '__main__':

    app = QApplication([])

    window = TopWidget()

    sys.exit(app.exec_())
